package com.helloUIBinder.server;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

@Component
@Path("/securityContextHolderService")
public class SecurityContextHolderService {

    @GET
    @Path("/username")
    @Produces("application/json")
    @Transactional
    public String getAllBlogPosts() {
        return SecurityContextHolder.getContext().getAuthentication().getName();
    }
}
